<?xml version='1.0' encoding='ISO-8859-1' ?>
<ui:composition template="/template/template_main.xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="cssImports">
	</ui:define>
	
	<ui:define name="jsImports">
	</ui:define>

	<ui:define name="breadcrumb">
		<p:breadCrumb>  
		    <p:menuitem value="TelaInicial" action="#{clienteBean.scheduleBean.telaInicial()}" ajax="false"/>  
		    <p:menuitem value="Efetuar Venda" action="#{efetuarVendaBean.iniciarTela()}" ajax="false" />  
		    <p:menuitem value="Selecionar o Cliente" />  
		</p:breadCrumb>  
	</ui:define>
	<ui:param name="titulo" value="Selecionar o Cliente" />
	
	<ui:define name="body_content">

		<h:panelGrid cellpadding="0" cellspacing="0" columns="1" styleClass="CorpoPagina" border="0" >
			<p:fieldset legend="BUSCA" toggleable="true" collapsed="true">
				<h:panelGroup id="tabela-filtro-cliente" >
					<h:panelGrid cellpadding="1" cellspacing="0" columns="4" border="0" >
						<p:outputLabel value="Nome:" for="txtNome" styleClass="HtmlOutputLabelResposta" />
						<p:inputText id="txtNome" value="#{efetuarVendaBean.nomeFiltro}" size="50" maxlength="45" styleClass="input-5left"/>
						
						<p:outputLabel value="Celular:" for="txtCelular" style="margin-left:5px;" styleClass="HtmlOutputLabelResposta" />
						<p:inputText id="txtCelular" value="#{efetuarVendaBean.celularFiltro}" alt="cell9" styleClass="input-5left"/>
						
						<p:outputLabel value="E-MAIL:" for="txtEmail" styleClass="HtmlOutputLabelResposta" />
						<p:inputText id="txtEmail" value="#{efetuarVendaBean.emailFiltro}" size="50" maxlength="45" styleClass="input-5left"/>
						
						<h:panelGroup > </h:panelGroup>
	
					</h:panelGrid>
				</h:panelGroup>
				<h:panelGroup >
					<div class="buttonFilter">
						<p:commandButton value="#{msgs.btn_limpar}" action="#{efetuarVendaBean.limparCamposFiltro()}" ajax="true"  update="tabela-filtro-cliente" />
						<p:commandButton value="#{msgs.btn_pesquisar}" action="#{efetuarVendaBean.pesquisarFiltro()}" ajax="true" style="margin-left:5px;" update="messagesGlobal tabela-selecao-cliente" />
					</div>
				</h:panelGroup>
			</p:fieldset>
			
			<hr class="lin" />
		
			<h:panelGroup id="tabela-selecao-cliente" >
				<h:panelGrid cellpadding="0" cellspacing="0" columns="1" styleClass="centralizar-conteudo" >
					<p:dataTable id="tableConClientes" 
							style="margin-top:20px;"
							var="result" rows="10" rowKey="#{result}" 
							selectionMode="single"
							selection="#{efetuarVendaBean.clienteSelecionado}"
							value="#{efetuarVendaBean.listaClientes}" 
							paginator="true" paginatorPosition="bottom" 
							emptyMessage="">
	
						<p:ajax event="rowSelect" update=":formGlobal:efetVenda" />
						<p:ajax event="rowUnselect" update=":formGlobal:efetVenda" />
						
						<f:facet name="header">  
				           Clientes Cadastradas
				        </f:facet>
						
						<p:column headerText="NOME" width="35%">
							<h:outputLabel value="#{result.dadosPessoa.nome}"
								style="text-align: left;" />
						</p:column>
						<p:column headerText="E-MAIL" width="35%">
							<h:outputLabel value="#{result.dadosPessoa.email}"
								style="text-align: left;" />
						</p:column>
						<p:column headerText="CELULAR" style="text-align: center;"
							width="10%">
							<h:outputLabel value="#{result.numCelularString}"
								style="text-align: center;" />
						</p:column>
						<p:column headerText="DATA DA PRIMEIRA VENDA"
							style="text-align: center;" width="10%">
							<h:outputLabel value="#{result.dataPrimeiraVenda}"
								style="text-align: center;">
								<f:convertDateTime pattern="dd/MM/yyyy" />
							</h:outputLabel>
						</p:column>
					</p:dataTable>
					
					<hr class="lin" />
					
					<h:panelGroup>
						<div class="buttonFooter">
							<p:commandButton id="btnVoltar" value="Voltar" ajax="false" action="/index" styleClass="botao-voltar"/>
							<p:commandButton id="efetVenda"
								value="#{msgs.btn_avancar}" 
								ajax="false" action="#{efetuarVendaBean.navegarSelecionarProdutos()}"
								disabled="#{empty efetuarVendaBean.clienteSelecionado}" />
							<div style="height: 10px;width: 10px;"></div>	
						</div>	
					</h:panelGroup>
					
				</h:panelGrid>
			</h:panelGroup><!-- FIM DO GROUP |id=tabela-selecao-cliente| -->
			
	</h:panelGrid>
	</ui:define>

</ui:composition>